package com.example.events;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 事件机制
 */
public class Example {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext =
                new AnnotationConfigApplicationContext(EventsConfig.class);

        applicationContext.publishEvent(new UserLoginEvent(applicationContext, "User user1 logged in"));
        applicationContext.publishEvent(new UserRegisterEvent(applicationContext, "User user2 registered"));

        applicationContext.close();
    }
}
